package com.xuanyuanzi.all_learning.web.controller.sys;

import com.wf.captcha.utils.CaptchaUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author chen.xuan
 * @Description TODO
 * @date 2024/10/28 9:22
 */
@RestController
public class LoginController {
    /**
     * 登录
     *
     * @paramrequest
     * @paramresponse
     */
    @PostMapping("/login")
    public void login(HttpServletRequest request, HttpServletResponse response) throws IOException {
//获取验证码参数
        String captcha = request.getParameter("captcha");
//校验验证码是否正确
        if (CaptchaUtil.ver(captcha, request)) {
            response.getOutputStream().print("captchacorrect!");
        } else {
            response.getOutputStream().print("captchaerror!");
        }
    }
}
